//
//  BaseViewController.m
//  cm
//
//  Created by suyibaishan on 2017/10/25.
//  Copyright © 2017年 feihu. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.hidden = YES;
    //    self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
    
    _baseBarHeight = statusBarRect.size.height + self.navigationController.navigationBar.frame.size.height;
    
    _baseBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, _baseBarHeight)];
    _baseBar.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_baseBar];
    
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth-180)/2, statusBarRect.size.height, 180, 44)];
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _titleLabel.textColor = [UIColor blackColor];
    _titleLabel.font = [UIFont boldSystemFontOfSize:17];
    [_baseBar addSubview:_titleLabel];
    
    _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _backButton.frame = CGRectMake(0, statusBarRect.size.height, 40, 44);
    _backButton.hidden = YES;
    [_backButton setImage:[UIImage imageNamed:@"navBack"] forState:UIControlStateNormal];
    [_backButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [_baseBar addSubview:_backButton];
    
    _barline = [[UIView alloc] init];
    _barline.backgroundColor = [UIColor colorWithRed:0.7 green:0.7 blue:0.7 alpha:1];
    [_baseBar addSubview:_barline];
    _barline.sd_layout
    .leftSpaceToView(_baseBar, 0)
    .bottomSpaceToView(_baseBar, 0)
    .widthIs(kScreenWidth)
    .heightIs(0.5);
    
    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)backButtonClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if (self.hidesBottomBarWhenPushed == NO) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"RECOVERAUDIOPLAYER" object:nil];
    }
}

- (void)showMessage:(NSString *)message
{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提醒" message:message preferredStyle:UIAlertControllerStyleAlert];
    [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
    [self presentViewController:alertController animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
